package com.mocha.bss.domain.org.output;

import com.mocha.bss.domain.org.convert.OrgConverter;
import com.mocha.bss.domain.org.repository.MochaUserRepository;
import com.mocha.bss.org.dto.UserDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Facade ：表示 内部通过feign 调用该接口；
 * @author songkui
 * @since 2022-02-11
 * @version v2.0
 */
@Slf4j
@RestController
@RequestMapping("/feign/user")
@AllArgsConstructor
public class UserFacade {

    private final MochaUserRepository mochaUserRepository;
    private final OrgConverter outputConverter;

    @PostMapping("/facade/test")
    public boolean testFacade(@RequestBody UserDTO userPo) {
        log.info("Register user {}", userPo.toString());
        return mochaUserRepository.save(outputConverter.toUserEntity(userPo));
    }



}
